package com.example.msai.entity;

import com.example.msai.config.CoordinateDeserializer;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@JsonDeserialize(using = CoordinateDeserializer.class)
public class Coordinate {
    private double latitude;
    private double longitude;
    @JsonCreator
    public Coordinate(@JsonProperty("coordinates") double[] coordinates) {
        if (coordinates != null && coordinates.length == 2) {
            this.longitude = coordinates[0];
            this.latitude = coordinates[1];
        }
    }
    public Coordinate(double longitude, double latitude) {
        this.longitude = longitude;
        this.latitude = latitude;
    }
}
